package com.nk.system.utils;

public class HashCodeCalculator {

    public static int hash(boolean h) {
        return h ? 0 : 1;
    }

    public static int hash(byte h) {
        return (int) h;
    }

    public static int hash(char h) {
        return (int) h;
    }

    public static int hash(short h) {
        return (int) h;
    }

    public static int hash(int h) {
        return (int) h;
    }

    public static int hash(long h) {
        return (int) (h ^ (h >>> 32));
    }

    public static int hash(float h) {
        return Float.floatToIntBits(h);
    }

    public static int hash(double h) {
        return HashCodeCalculator.hash(Double.doubleToLongBits(h));
    }

    public static int hash(Object h) {
        return h == null ? 0 : h.hashCode();
    }

    public static int hash(boolean h, int result) {
        return result * 37 + HashCodeCalculator.hash(h);
    }

    public static int hash(byte h, int result) {
        return result * 37 + HashCodeCalculator.hash(h);
    }

    public static int hash(char h, int result) {
        return result * 37 + HashCodeCalculator.hash(h);
    }

    public static int hash(short h, int result) {
        return result * 37 + HashCodeCalculator.hash(h);
    }

    public static int hash(int h, int result) {
        return result * 37 + HashCodeCalculator.hash(h);
    }

    public static int hash(long h, int result) {
        return result * 37 + HashCodeCalculator.hash(h);
    }

    public static int hash(float h, int result) {
        return result * 37 + HashCodeCalculator.hash(h);
    }

    public static int hash(double h, int result) {
        return result * 37 + HashCodeCalculator.hash(h);
    }

    public static int hash(Object h, int result) {
        return result * 37 + HashCodeCalculator.hash(h);
    }
}
